# coding: utf-8
from sqlalchemy import Column, INT
from sqlalchemy_dm import VARCHAR, DATE, DATETIME ,NUMBER
from sqlalchemy.ext.declarative import declarative_base

# 创建对象的基类
Base = declarative_base()

# 用户类
class ActualController(Base):
    # 用户
    __table_args__ = {'schema': 'ESUNTEST'}
    # 表名
    __tablename__ = 'HX_BI_SJKZR'
    # 表结构
    ID = Column(INT, primary_key=True, autoincrement=True)
    NAME = Column(VARCHAR(128))
    GSMC = Column(VARCHAR(128))
    RATIO = Column(VARCHAR(128))
    HID = Column(VARCHAR(256))
    GID = Column(VARCHAR(256))
    HPID = Column(VARCHAR(256))
    TYPE = Column(NUMBER)
    PCH = Column(VARCHAR(256))
    IMPORT = Column(NUMBER)
    IS_CYDW = Column(NUMBER)

    @classmethod
    def from_dict(cls, data):
        return cls(
            ID  =data['ID'],
            NAME=data['NAME'],
            GSMC=data['GSMC'],
            RATIO=data['RATIO'],
            HID=data['HID'],
            GID=data['GID'],
            HPID=data['HPID'],
            TYPE=data['TYPE'],
            PCH=data['PCH'],
            IMPORT=data['IMPORT'],
            IS_CYDW=data['IS_CYDW']
        )

    def to_all_dict(self):
        return {
            'ID'  : self.ID,
            'NAME': self.NAME,
            'GSMC': self.GSMC,
            'RATIO': self.RATIO,
            'HID': self.HID,
            'GID': self.GID,
            'HPID': self.HPID,
            'TYPE': self.TYPE,
            'PCH': self.PCH,
            'IMPORT': self.IMPORT,
            'IS_CYDW': self.IS_CYDW
        }

    def to_dict(self):
        return {
            'ID'  : self.ID,
            'NAME': self.NAME,
            'GSMC': self.GSMC,
            'RATIO': self.RATIO,
            'HID': self.HID,
            'GID': self.GID,
            'HPID': self.HPID,
            'TYPE': self.TYPE,
            'PCH': self.PCH,
            'IMPORT': self.IMPORT,
            'IS_CYDW': self.IS_CYDW
        }
